import Loadable from 'react-loadable'

// 转载加载组件
function Loading(props) {
  if (props.error) {
    return (
      <div>
        Error! <button onClick={props.retry}>Retry</button>
      </div>
    )
  } else {
    return <div>Loading...</div>
  }
}

export default function withLoadable(Component) {
  return Loadable({
    loader: Component,
    loading: Loading,
  })
}
